﻿
#region

using System.Web.Mvc;
using Should;
using TechTalk.SpecFlow;
using UserStoryTrackerDemo.Specs.Steps.Watin;
using WatiN.Core;

#endregion

namespace UserStoryTrackerDemo.Specs.Steps
{
	[Binding]
	public class CompleteUserStorySteps : UserStoryStepsBase
	{
		private ViewResult _userStoryListResult;

		[Given(@"I am on the view user story page")]
		public void GivenIAmOnTheViewUserStoryPage()
		{
			_userStoryListResult = NavigateToListPage();
			WhenIClickViewUserStory();
		}

		[When(@"I click ""Set Complete""")]
		public void WhenIClickSetComplete()
		{
			WebBrowser.Current.Links.First(Find.ByText("Set Complete")).Click();
		}

		[When(@"I click ""View User Story""")]
		public void WhenIClickViewUserStory()
		{
			WebBrowser.Current.Links.First(Find.ByText("View User Story")).Click();
		}

		[Then(@"I am on the view user story page")]
		public void ThenIAmOnTheViewUserStoryPage()
		{
			WebBrowser.Current.Title.ShouldContain("User Story Details");
		}

		[Then(@"I should see a link ""Set Complete""")]
		public void ThenIShouldSeeALinkSetComplete()
		{
			var matchingFields = WebBrowser.Current.Links.Filter(Find.ByText("Set Complete"));
			matchingFields.Count.ShouldEqual(1);
		}
	}
}